package com.gitee.wsl.mathematics.vector.ext

import androidx.annotation.FloatRange
import com.gitee.wsl.mathematics.vector.vec2.Vector2
import com.gitee.wsl.mathematics.vector.vec3.Vector3
import com.gitee.wsl.mathematics.vector.vec4.Vector4

fun <T:Number,K: Vector2<T, K>> Vector2<T, K>.mix(o: Vector2<T, K>,@FloatRange(from = 0.0, to = 1.0) mix: Double) = this * (1 - mix) + o * mix

fun <T:Number,K: Vector3<T, K>> Vector3<T, K>.mix(o: Vector3<T, K>, @FloatRange(from = 0.0, to = 1.0) mix: Double) = this * (1 - mix) + o * mix

fun <T:Number,K: Vector4<T, K>> Vector4<T, K>.mix(o: Vector4<T, K>, @FloatRange(from = 0.0, to = 1.0) mix: Double) = this * (1 - mix) + o * mix

fun <T:Number,K: Vector2<T, K>> Vector2<T, K>.mix(o: Vector2<T, K>, mix: Vector2<T, K>)
  = create(
      mix(this.x,o.x,mix.x),
      mix(this.y,o.y,mix.y)
  )

fun <T:Number,K: Vector3<T, K>> Vector3<T, K>.mix(o: Vector3<T, K>, mix:Vector3<T, K>)
= create(
    mix(this.x,o.x,mix.x),
    mix(this.y,o.y,mix.y),
    mix(this.z,o.z,mix.z)
)

fun <T:Number,K: Vector4<T, K>> Vector4<T, K>.mix(o: Vector4<T, K>, mix: Vector4<T, K>)
= create(
    mix(this.x,o.x,mix.x),
    mix(this.y,o.y,mix.y),
    mix(this.z,o.z,mix.z),
    mix(this.w,o.w,mix.w),
)